﻿<!--
    Copyright (C) 2011 Ari Rokosa, Chinedu Eze, Johannes Virtanen,
                       Petri Tuononen, Timo Korkalainen

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
<div id="desktop-container">
    @{Html.RenderAction("Index","Desktop");}
</div>

<div id="header-container">
    @{Html.RenderAction("Index","Header");}
</div>

<div id="desktop-list-container">
    @{Html.RenderAction("Index","Desktoplist");}
</div>

<script type="text/javascript">

    hover_user_list = 0;
    visible_user_list = true;

</script>
@{if (ViewBag.login == true)
 {
      
<div id="user-list-container">
    <ul id="user-list" class="side-list">
    </ul>
</div>
<div id="user-list-hover"></div>
    
<script type="text/javascript">

    function refreshUserlist() {
        $.post("Userlist/Index", function (data) {
            $('#user-list').html(data);
        });
    }

    function hoverUserList() {

        switch (hover_user_list) {
            case 0:
                if (visible_user_list === true) {
                    var left = $(window).width() - ($('#user-list').width() * 0.1);
                    $('#user-list-container').animate({ "left": left + "px" }, 'fast');
                    visible_user_list = false;
                }
                break;

            case 1:
                if (visible_user_list === false) {
                    var left = $(window).width() - ($('#user-list').width());
                    $('#user-list-container').animate({ "left": left + "px" }, 'fast');
                    visible_user_list = true;
                }
                setTimeout(function () { hoverUserList(); }, 2000);
                break;

            default:
                setTimeout(function () { hoverUserList(); }, 2000);
        }
    };

    refreshUserlist();
    hoverUserList();

    var refreshUserListId = setInterval("refreshUserlist()", 9000);
      
    $("#user-list").mouseleave(function () { hover_user_list--; });
    $("#user-list").mouseenter(function () { hover_user_list++; hoverUserList(); });
    $("#user-list-hover").mouseenter(function () { hover_user_list++; hoverUserList(); });
    $("#user-list-hover").mouseleave(function () { hover_user_list--; });
    </script>
  }
}

@{if (ViewBag.login == true)
  {
<div id="topics-container">
    @{Html.RenderAction("Index", "Topics");}
</div>
  }}

@{if (ViewBag.login == true)
  {
<div id="chat-container">
    @{Html.RenderAction("Index", "Chat");}
</div>
}}

<div id="dialog-background"></div>

<script type="text/javascript">
    $('#dialog-background').click(function () { $('.dialog').remove(); $('#dialog-background').hide(); });
    //var desktopRefreshId = setInterval("refreshDesktop()", 10000);
</script>